fix(flags): preserve parsed flags when --help is combined with -D#37
Merged
seanseannery merged 1 commit intomainfrom Mar 7, 2026
Merged
fix(flags): preserve parsed flags when --help is combined with -D#37seanseannery merged 1 commit intomainfrom
seanseannery merged 1 commit intomainfrom
Conversation
ParseOpsFlags was returning a zero-value OpsFlags when ErrHelp was triggered, discarding any flags parsed before --help/-h/-?. This caused the --help path in main.go to ignore -D and fail to find the Opsfile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Changes
ParseOpsFlagsnow returns populatedOpsFlagsalongsideErrHelpinstead of a zero-value struct, so flags like-Dparsed before--help/-h/-?are preserved-?handler now strips-?from args and still runsfs.Parseon the remaining flags before returningErrHelp-Dis preserved when combined with each help variant (--help,-h,-?)wantFlagseven in error casesWhy do we need this?
When
-D /path --helpwas passed, the--helppath inmain.gousedflags.Directoryto locate the Opsfile for the command listing. ButParseOpsFlagswas returningOpsFlags{}(zero value) on all help paths, soflags.Directorywas always empty and the Opsfile was never found. This broke the--help+-Dintegration added in #36.Related to #19
New modules or other dependencies introduced
None
How was this tested?
-D combined with --help,-D combined with -h,-D combined with -?— all verifyOpsFlags.Directoryis populated alongsideErrHelpops -D ./examples --helpnow shows the command listingmake lintandmake testpass